package com.ningmengs789.live.ui.adapter;


import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.ningmengs789.live.R;
import com.ningmengs789.live.model.CategoryListDTO;
import com.ningmengs789.live.utils.GlideUtil;

import java.util.List;

/**
 * 作者 : Administrator (yzhg)
 * 时间 : 2021-09-08 09:39
 * 包名 : com.ningmengs789.live.ui.shopping.ui.fragment
 * 备注：
 */
public class ShoppingHomeAdapter extends BaseRecyclerViewAdapter {


    public ShoppingHomeAdapter(Context context, List data, int layoutId) {
        super(context, data, layoutId);
    }

    @Override
    protected void onBindData(RecyclerViewHolder holder, Object bean, int position) {
        //转化为实体对象
        CategoryListDTO categoryListDTO = (CategoryListDTO) bean;
        //图标
        ImageView ivNavigationIcon = holder.itemView.findViewById(R.id.iv_navigation_icon);

        //title
        TextView tvNavigationTitle = holder.itemView.findViewById(R.id.tv_navigation_title);


        if (categoryListDTO.getId() == -1) {
            //设置图标
            GlideUtil.loadImageViewCrop(mContext, R.drawable.navigation_more, ivNavigationIcon, R.drawable.ic_default_image);
            //设置图片标题
            tvNavigationTitle.setText("更多");
        } else {
            //设置图标
            GlideUtil.loadImageViewCrop(mContext, categoryListDTO.getImage(), ivNavigationIcon, R.drawable.ic_default_image);
            //设置图片标题
            tvNavigationTitle.setText(categoryListDTO.getName());
        }

    }
}
